package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.controller.viewobject.ContractMaintainGetVO;
import com.chinairi.mall.controller.viewobject.ContractMaintainVO;
import com.chinairi.mall.model.HomePicType;
import com.chinairi.mall.service.IHomePicTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-09-09
 */
@RestController
@RequestMapping("/home-pic-type")
public class HomePicTypeController extends BaseController {
    @Autowired
    private IHomePicTypeService iHomePicTypeService;

    /**
     * 配置图片类型
     *
     * @param homePicType 图片类型对象
     */
    @PostMapping("/config")
    @ResponseBody
    public void config(@RequestBody HomePicType homePicType) throws IOException {
        iHomePicTypeService.config(homePicType);
        ResponseUtil.showMessage("success","图片类型添加成功", null);
    }

    /**
     * 更新图片类型表
     *
     * @param homePicType 图片类型对象
     */
    @PutMapping("/update")
    @ResponseBody
    public void update(HomePicType homePicType) throws IOException {
        iHomePicTypeService.update(homePicType);
        ResponseUtil.showMessage("success","图片类型更新成功", null);
    }

    /**
     * 删除图片类型
     *
     * @param uuid 主键
     */
    @DeleteMapping("/delete")
    @ResponseBody
    public void delete(String uuid) throws IOException {
        iHomePicTypeService.delete(uuid);
        ResponseUtil.showMessage("success","删除图片类型成功!", null);
    }

    /**
     * 获取所有图片类型列表
     *
     */
    @GetMapping("/get")
    @ResponseBody
    public void getList() throws IOException {
        List<HomePicType> list =iHomePicTypeService.get();
        ResponseUtil.showMessage("success","获取图片类型列表", list);
    }
}
